package com.ruoyi.project.WebMoudle.onlineCoupon.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.WebMoudle.onlineCoupon.mapper.OnlineCouponMapper;
import com.ruoyi.project.WebMoudle.onlineCoupon.domain.OnlineCoupon;
import com.ruoyi.project.WebMoudle.onlineCoupon.service.IOnlineCouponService;
import com.ruoyi.common.utils.text.Convert;

/**
 * 优惠券Service业务层处理
 * 
 * @author ruoyi
 * @date 2020-07-09
 */
@Service
public class OnlineCouponServiceImpl implements IOnlineCouponService 
{
    @Autowired
    private OnlineCouponMapper onlineCouponMapper;

    /**
     * 查询优惠券
     * 
     * @param id 优惠券ID
     * @return 优惠券
     */
    @Override
    public OnlineCoupon selectOnlineCouponById(Long id)
    {
        return onlineCouponMapper.selectOnlineCouponById(id);
    }

    /**
     * 查询优惠券列表
     * 
     * @param onlineCoupon 优惠券
     * @return 优惠券
     */
    @Override
    public List<OnlineCoupon> selectOnlineCouponList(OnlineCoupon onlineCoupon)
    {
        return onlineCouponMapper.selectOnlineCouponList(onlineCoupon);
    }

    /**
     * 新增优惠券
     * 
     * @param onlineCoupon 优惠券
     * @return 结果
     */
    @Override
    public int insertOnlineCoupon(OnlineCoupon onlineCoupon)
    {
        onlineCoupon.setCreateTime(DateUtils.getNowDate());
        return onlineCouponMapper.insertOnlineCoupon(onlineCoupon);
    }

    /**
     * 修改优惠券
     * 
     * @param onlineCoupon 优惠券
     * @return 结果
     */
    @Override
    public int updateOnlineCoupon(OnlineCoupon onlineCoupon)
    {
        onlineCoupon.setUpdateTime(DateUtils.getNowDate());
        return onlineCouponMapper.updateOnlineCoupon(onlineCoupon);
    }

    /**
     * 删除优惠券对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteOnlineCouponByIds(String ids)
    {
        return onlineCouponMapper.deleteOnlineCouponByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除优惠券信息
     * 
     * @param id 优惠券ID
     * @return 结果
     */
    @Override
    public int deleteOnlineCouponById(Long id)
    {
        return onlineCouponMapper.deleteOnlineCouponById(id);
    }

    @Override
    public int updateExpire() {
        return onlineCouponMapper.updateExpire();
    }

    @Override
    public int changeStatus(Long couponId, String status) {
        return onlineCouponMapper.changeStatus(couponId,status);
    }
}
